package com.wiscamp.ninechapters.problems.domain.repositories;

import com.wiscamp.ninechapters.problems.domain.models.collections.CollectionProblem;
import com.wiscamp.ninechapters.problems.domain.models.collections.ProblemCollection;
import cube.ddd.common.query.PagedObjects;
import cube.ddd.common.query.PagedQuery;
import jakarta.validation.constraints.Min;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;

import java.util.Collection;

public interface ProblemCollectionRepository {

    // region problem collection
    Collection<Long> getProblemIdsByCollection(long collectionId);

    ProblemCollection getProblemCollection(long collectionId);

    ProblemCollection getProblemCollectionByCode(@NotBlank String collectionCode, @Min(0) long organizationId);

    Collection<ProblemCollection> getProblemCollectionsByName(@NotBlank String collectionName, @Min(0) long organizationId);

    Collection<ProblemCollection> getProblemCollectionsByNameContains(@NotBlank String name, @Min(0) long organizationId);

    Collection<ProblemCollection> getProblemCollectionsByNameContains(@NotBlank String name, @Min(0) long organizationId, @NotBlank String gradeLevel);

    Collection<ProblemCollection> getProblemCollectionsByOrganization(@Min(0) long organizationId);

    Collection<ProblemCollection> getProblemCollectionsByExam(@Min(0) long examId);

    PagedObjects<ProblemCollection> getProblemCollectionsByQuery(@NotNull PagedQuery query);

    ProblemCollection saveProblemCollection(@NotNull ProblemCollection collection);

    long getExamIdByCollection(long collectionId);
    // endregion

    // region collection problem

    CollectionProblem getCollectionProblem(long id);

    CollectionProblem getCollectionProblemByProblem(long problemId);

    CollectionProblem getCollectionProblemByProblem(long collectionId, long problemId);

    Collection<CollectionProblem> getCollectionProblems(long collectionId);

    CollectionProblem saveCollectionProblem(@NotNull CollectionProblem collectionProblem);

    boolean deleteCollectionProblem(long id);

    boolean updateProblemQuantity(@Min(0) long collectionId);

    int getMaxProblemIndex(@Min(0) long collectionId);

    CollectionProblem getCollectionProblemByIndex(long collectionId, int index);

    long getProblemIdByIndex(@Min(0) long collectionId, @Min(0) int index);

    boolean resortProblemIndex(long collectionId, int index);
    // endregion
}
